﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace thinger.VisionControlLib
{
    public enum State
    {
        Done,
        Error,
        Excute,
        None
    }
    public partial class ExcuteState : UserControl
    {
        public ExcuteState()
        {
            InitializeComponent();
        }

        private State state=State.Done;

        public State State
        {
            get { return state; }
            set { state = value;

                if (this.InvokeRequired)
                {
                    this.Invoke(new Action<State>(SetState), state);
                }
                else
                {
                    SetState(state);
                }
            }
        }
        private void SetState(State state)
        {
            switch (state)
            {
                case State.Done:
                    Visible = true;
                    this.BackgroundImage = Properties.Resources.done;
                    break;
                case State.Error:
                    Visible = true;
                    this.BackgroundImage = Properties.Resources.error;
                    break;
                case State.Excute:
                    Visible = true;
                    this.BackgroundImage = Properties.Resources.loop;
                    break;
                case State.None:
                    Visible = false;
                    break;
                default:
                    break;
            }
        }
    }
}
